﻿using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Class;

namespace Web.Controls.LAIHAN
{
    public partial class UCLHYueDuTZRightInfo : System.Web.UI.UserControl, IUCLHOperate
    {

      
        private int _LAIHANLX;
        /// <summary>
        /// 来函类型
        /// </summary>
        public int LAIHANLX
        {
            get { return _LAIHANLX; }
            set { _LAIHANLX = value; }
        }
        private int _LAIHANLCBH;
        /// <summary>
        /// 来函流程状态
        /// </summary>
        public int LAIHANLCBH
        {
            get { return _LAIHANLCBH; }
            set { _LAIHANLCBH = value; }
        }

        
        #region 变量
        /// <summary>
        /// 来函信息
        /// </summary>
        YS_LH_LAIHANXXProcess blllh = new YS_LH_LAIHANXXProcess();

        /// <summary>
        /// 来函用户信息
        /// </summary>
        YS_LH_YONGHUXXProcess laihanyhxx = new YS_LH_YONGHUXXProcess();

        /// <summary>
        /// 访问数据库
        /// </summary>
        SpHelper _sphelper = new SpHelper();

        /// <summary>
        /// 月调整
        /// </summary>
        YS_LH_YUETIAOZProcess bllyue = new YS_LH_YUETIAOZProcess();
        /// <summary>
        /// 管理块
        /// </summary>
        YS_JX_GUANLIKBLL glkbll = new YS_JX_GUANLIKBLL();
        /// <summary>
        /// 流程
        /// </summary>
        YS_LH_LAIHANLCJLBLL lcbll = new YS_LH_LAIHANLCJLBLL();

        /// <summary>
        /// 用户信息
        /// </summary>
        YS_YG_YONGHUXXBLL yhbll = new YS_YG_YONGHUXXBLL();

        /// <summary>
        /// 账号信息
        /// </summary>
        AS_UserInfoBLL userbll = new AS_UserInfoBLL();


        #endregion
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }
       
        protected void btnActPerform_Click(object sender, EventArgs e)
        {
            UCLHLCLAIHANXX uc = this.Parent.FindControl("UCLHLCLAIHANXX") as UCLHLCLAIHANXX;
            string GuanLik = null;
            if (HiddenList.Get("h_glk").ToString().Trim().Length > 0)
            {
                GuanLik = HiddenList.Get("h_glk").ToString();
            }
            uc.BindList(GuanLik, txtLaiHanBH.Text.Trim(), txtYongHuH.Text.Trim(), C_YwWuY.Value.ToString() == "-1" ? null : C_YwWuY.Value, CK_FuShenXG.Value);
        
        }
        public void InitControl()
        {
           
            DataTable dtZhandian = BusinessTool.GetTextAndValue("view_as_userinfo", "ZHANDIANMC", "ZHANDIANBH", null, string.Format("account='{0}'", LoginInfo.CurrentUser.UserID.ToString())).Tables[0];
            string zhandianBH = "";
            if (dtZhandian != null && dtZhandian.Rows.Count > 0)
            {
                zhandianBH = dtZhandian.Rows[0]["VALUE"].ToString();
               
            }
            if (zhandianBH == "")
            {
                zhandianBH = "51";
               
            }
            PageTools.LoadCombox(C_YwWuY, PageTools.eLoadType.业务员, zhandianBH, "", "");
            DataTable glkdt = glkbll.SelectYS_JX_GUANLIKsDynamic(" I_JLZT=0 and (S_ZHANDIAN='" + zhandianBH + "' or 00='" + zhandianBH + "')", " S_ZHanDIan");

            C_GuanLiK.DataSource = glkdt;
            C_GuanLiK.TextField = "S_GUANLIKMC";
            C_GuanLiK.ValueField = "S_GUANLIKH";
            C_GuanLiK.DataBind();
            SetDisplay();
            C_GuanLiK.SelectedIndex = 0;
            if (glkdt != null && glkdt.Rows.Count > 0)
            {
                HiddenList.Set("h_glk", glkdt.Rows[0]["S_GUANLIKH"].ToString());
               
            }
            UCLHLCLAIHANXX uc = this.Parent.FindControl("UCLHLCLAIHANXX") as UCLHLCLAIHANXX;
            string GuanLik = null;
            if (HiddenList.Get("h_glk").ToString().Trim().Length > 0&&string.IsNullOrEmpty(Request["ID"]))
            {
                GuanLik = HiddenList.Get("h_glk").ToString();
            }
            uc.BindList(GuanLik, txtLaiHanBH.Text.Trim(), txtYongHuH.Text.Trim(), C_YwWuY.Value.ToString() == "-1" ? null : C_YwWuY.Value, CK_FuShenXG.Value);
      

        }

        public ValidateRS Validate()
        {
            ValidateRS rs = new ValidateRS();
            int qrl = 0;
            rs.IsSuccess = false;
            if (this.LAIHANLCBH == 30)///业务员操作
            {
                if (!int.TryParse(txtYeWuJYL.Text, out qrl))
                {

                    rs.Msg = "建议量输入错误";
                    return rs;
                 
                }
                if (txtYeWuYJY.Text.Trim().Length == 0)
                {

                    rs.Msg = "请输入业务员意见";
                    return rs;
                  
                   
                }
               
            }
            if (this.LAIHANLCBH == 40)
            {
                if (!int.TryParse(txtI_ZhuRenFHL.Text, out qrl))
                {

                    rs.Msg = "复核量输入错误";
                    return rs;
                  
                   
                }
                if (txtZhuRenYJ.Text.Trim().Length == 0)
                {

                    rs.Msg = "请输入主任意见";
                    return rs;
                  
                }
               
            }
            if (this.LAIHANLCBH == 50)
            {
              
                if (!int.TryParse(txtI_JieShuiKZSHL.Text, out qrl))
                {
                    rs.Msg = "审核量输入错误";
                    return rs;
                  
                }
                if (txtS_JieShuiKZSHL.Text.Trim().Length == 0)
                {
                    rs.Msg = "请输入节水科长意见";
                    return rs;
                  
                }
               
            }
            if (this.LAIHANLCBH == 60)
            {
                if (!int.TryParse(txtI_JiCaiKZFSL.Text, out qrl))
                {
                    rs.Msg = "复审量输入错误";
                    return rs;
                   
                }
                if (txtS_JiCaiKZFSL.Text.Trim().Length == 0)
                {
                    rs.Msg = "请输入计财科长意见";
                    return rs;
                  
                }
               
            }
            if (this.LAIHANLCBH == 70)
            {
                if (!int.TryParse(txtI_ChuZhangSPL.Text, out qrl))
                {
                    rs.Msg = "审批量输入错误";
                    return rs;
                   
                }
                if (txtS_ChuZhangYJ.Text.Trim().Length == 0)
                {
                    rs.Msg = "请输入处长意见";
                    return rs;
                   
                }
              
            }
            rs.IsSuccess = true;
            return rs;
        }

        public void ClearInfo()
        {
            throw new NotImplementedException();
        }

        public void LoadInfo(Entity.YS_LH_LAIHANXX laihanxx)
        {
            HiddenList.Set("h_laihanbh", laihanxx.S_LAIHANBH);
            txtXingZhengXKSLBH.Text = laihanxx.S_XUKEBH;
            txtTongYiSPBH.Text = laihanxx.S_TONGYIBM;
            DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH='{0}' and I_LIUCHENGBH={1} ", laihanxx.S_LAIHANBH, 2), "", null);
            if (lcxx != null && lcxx.Rows.Count > 0)
            {
                txtShouLiRQ.Text = Convert.ToDateTime(lcxx.Rows[0]["D_StartDate"]).ToString("yyyy-MM-dd");

            }
            int y = Convert.ToInt32(laihanxx.I_Y);
            int m = Convert.ToInt32(laihanxx.I_M);
            int? Errcode = 0;
            DataSet jhxx = _sphelper.P_YS_LH_YUEDUTZJHXXCX(BusinessTool.ZHANDIANBH(), y, m, laihanxx.S_YONGHUBH.Trim(), out Errcode);
            if (jhxx != null && jhxx.Tables.Count > 0 && jhxx.Tables[0] != null && jhxx.Tables[0].Rows.Count > 0)
            {
                DataRow dr = jhxx.Tables[0].Rows[0];
                txtShangYueCYE.Text = dr["V_ShangYueCYE"].ToString();
                txtShangYueJJE.Text = dr["V_ShangYuJJE"].ToString();
                txtShangYueSY.Text = dr["V_ShangYueSY"].ToString();

                txtChaoYongBL.Text = dr["V_ChaoYongBL"].ToString();
                txtChaoYongE.Text = dr["V_ChaoYongE"].ToString();
                txtChaoYongL.Text = dr["V_ChaoYongL"].ToString();
                txtGuBiaoL.Text = dr["V_GuBiaoL"].ToString();

                txtHuiGuanL.Text = dr["V_HuiGuanL"].ToString();
                txtJiaJiaJE.Text = dr["V_JiaJiaJE"].ToString();
                txtJiaJiaL.Text = dr["V_JiaJiaL"].ToString();
                txtJiaJiaLV.Text = dr["V_JiaJiaLv"].ToString() + "%";
                txtJiJianL.Text = dr["V_JiJianL"].ToString();


                txtYuanJiH.Text = dr["V_YuanJiH"].ToString();
                txtShiYongL.Text = dr["V_ShiYongL"].ToString();

                txtChaoYongJE.Text = dr["V_ChaoYongJE_Z"].ToString();
                txtJiaJiaJEZ.Text = dr["V_JiaJiaJE_Z"].ToString();
                txtJiaJiaLVZ.Text = dr["V_JiaJiaLv_Z"].ToString() + "%";
            }

            DataTable userdt = yhbll.SelectYS_YG_YONGHUXXesDynamic(string.Format(" S_YONGHUH='{0}' and I_LEIXING=0 and i_jlzt=0", laihanxx.S_YONGHUBH), "", null);

            if (userdt != null && userdt.Rows.Count > 0)
            {
                txtYongHuM.Text = userdt.Rows[0]["S_YONGHUM"].ToString();
                cFUFEI.Checked = (userdt.Rows[0]["I_CHENNUOFF"].ToString() == "1");
                cTUOSHOU.Checked = (userdt.Rows[0]["I_SHOUFEIFS"].ToString() == "1");

                DataTable user = BusinessTool.GetTextAndValue("view_as_userinfo", "UserID", "UserName", null, string.Format("UserID={0} ", userdt.Rows[0]["S_YEWUY"])).Tables[0];

                txtYeWuY.Text = user.Rows[0]["Value"].ToString();
            }
            DataTable yuetz = bllyue.SelectYS_LH_YUETIAOZsDynamic(string.Format("S_LAIHANBH='{0}'", laihanxx.S_LAIHANBH), "  ID desc", null);
            if (yuetz != null && yuetz.Rows.Count > 0)
            {
                txtYongHuSQL.Text = yuetz.Rows[0]["I_SHENQINGL"].ToString();

                txtYeWuYJY.Text = yuetz.Rows[0]["S_YEWUYJY"].ToString();
                txtYeWuJYL.Text = yuetz.Rows[0]["I_YEWUYJY"].ToString();
                txtZhuRenYJ_XS.Text = yuetz.Rows[0]["S_ZHUREN"].ToString();
                txtJieShuiKZYJ_XS.Text = yuetz.Rows[0]["S_JIESHUIKZ"].ToString();
                txtJiCcaiKZYJ_XS.Text = yuetz.Rows[0]["S_JICAIKZ"].ToString();
                txtChuZhangYJ_XS.Text = yuetz.Rows[0]["S_CHUZHANG"].ToString();

                txtYeWuYJYL.Text = yuetz.Rows[0]["I_YEWUYJY"].ToString();
                txtZhuRenFHL.Text = yuetz.Rows[0]["I_ZHUREN"].ToString();
                txtJieShuiKZSHL.Text = yuetz.Rows[0]["I_JIESHUIKZ"].ToString();
                txtJiCaiKZFSL.Text = yuetz.Rows[0]["I_JICAIKZ"].ToString();

                txtI_ZhuRenFHL.Text = yuetz.Rows[0]["I_ZHUREN"].ToString();
                txtI_JiCaiKZFSL.Text = yuetz.Rows[0]["I_JICAIKZ"].ToString();
                txtI_JieShuiKZSHL.Text = yuetz.Rows[0]["I_JIESHUIKZ"].ToString();
                txtI_ChuZhangSPL.Text = yuetz.Rows[0]["I_CHUZHANG"].ToString();

                txtZhuRenYJ.Text = yuetz.Rows[0]["S_ZHUREN"].ToString();
                txtS_JieShuiKZSHL.Text = yuetz.Rows[0]["S_JIESHUIKZ"].ToString();
                txtS_JiCaiKZFSL.Text = yuetz.Rows[0]["S_JICAIKZ"].ToString();
                txtS_ChuZhangYJ.Text = yuetz.Rows[0]["S_CHUZHANG"].ToString();

                //txtYeWuYYJ_XS.Text = yuetz.Rows[0]["S_YEWUYJY"].ToString();

            }
            txtYongHuSQL.Enabled = false;
            //txtLY.Enabled = false;

            txtYeWuYJY.Enabled = (txtYeWuYJY.Text.Trim().Length == 0);
            txtYeWuJYL.Enabled = (txtYeWuJYL.Text.Trim().Length == 0);

            txtI_ChuZhangSPL.Enabled = (txtI_ChuZhangSPL.Text.Trim().Length == 0);
            txtS_ChuZhangYJ.Enabled = (txtS_ChuZhangYJ.Text.Trim().Length == 0);

            txtI_JieShuiKZSHL.Enabled = (txtI_JieShuiKZSHL.Text.Trim().Length == 0);
            txtS_JieShuiKZSHL.Enabled = (txtS_JieShuiKZSHL.Text.Trim().Length == 0);

            txtI_JiCaiKZFSL.Enabled = (txtI_JiCaiKZFSL.Text.Trim().Length == 0);
            txtS_JiCaiKZFSL.Enabled = (txtS_JiCaiKZFSL.Text.Trim().Length == 0);

            txtI_ZhuRenFHL.Enabled = (txtI_ZhuRenFHL.Text.Trim().Length == 0);
            txtZhuRenYJ.Enabled = (txtZhuRenYJ.Text.Trim().Length == 0);
        }
        public void SaveQR()
        {
            string col = "I_YEWUYJY={0},S_YEWUYJY='{1}' ";
            string where = "S_LAIHANBH='{0}' ";
            int qrl = 0;

            if (this.LAIHANLCBH == 30)///业务员操作
            {
                if (!int.TryParse(txtYeWuJYL.Text, out qrl))
                {
                    PageTools.AlertMsg(this, "建议量输入错误");
                    return;
                }
                if (txtYeWuYJY.Text.Trim().Length == 0)
                {
                    PageTools.AlertMsg(this, "请输入业务员意见");
                    return;
                }
                col = "I_YEWUYJY={0},S_YEWUYJY='{1}' ";
                col = string.Format(col, qrl, txtYeWuYJY.Text);
            }
            if (this.LAIHANLCBH == 40)
            {
                if (!int.TryParse(txtI_ZhuRenFHL.Text, out qrl))
                {
                    PageTools.AlertMsg(this, "复核量输入错误");
                    return;
                }
                if (txtZhuRenYJ.Text.Trim().Length == 0)
                {
                    PageTools.AlertMsg(this, "请输入主任意见");
                    return;
                }
                col = "I_ZHUREN={0},S_ZHUREN='{1}' ";
                col = string.Format(col, qrl, txtZhuRenYJ.Text);
            }
            if (this.LAIHANLCBH == 50)
            {
                if (!int.TryParse(txtI_JieShuiKZSHL.Text, out qrl))
                {
                    PageTools.AlertMsg(this, "审核量输入错误");
                    return;
                }
                if (txtS_JieShuiKZSHL.Text.Trim().Length == 0)
                {
                    PageTools.AlertMsg(this, "请输入节水科长意见");
                    return;
                }
                col = "I_JIESHUIKZ={0},S_JIESHUIKZ='{1}' ";
                col = string.Format(col, qrl, txtS_JieShuiKZSHL.Text);
            }
            if (this.LAIHANLCBH == 60)
            {
                if (!int.TryParse(txtI_JiCaiKZFSL.Text, out qrl))
                {
                    PageTools.AlertMsg(this, "复审量输入错误");
                    return;
                }
                if (txtS_JiCaiKZFSL.Text.Trim().Length == 0)
                {
                    PageTools.AlertMsg(this, "请输入计财科长意见");
                    return;
                }
                col = "I_JICAIKZ={0},S_JICAIKZ='{1}' ";
                col = string.Format(col, qrl, txtS_JiCaiKZFSL.Text);
            }
            if (this.LAIHANLCBH == 70)
            {
                if (!int.TryParse(txtI_ChuZhangSPL.Text, out qrl))
                {
                    PageTools.AlertMsg(this, "审批量输入错误");
                    return;
                }
                if (txtS_ChuZhangYJ.Text.Trim().Length == 0)
                {
                    PageTools.AlertMsg(this, "请输入处长意见");
                    return;
                }
                col = "I_CHUZHANG={0},S_CHUZHANG='{1}' ";
                col = string.Format(col, qrl, txtS_ChuZhangYJ.Text);
            }

            where = string.Format(where, HiddenList.Get("h_laihanbh"));
            int success = bllyue.UpdateYS_LH_YUETIAOZsDynamic(col, where);
            
        }
        public void LaiHanXXTJ(CallbackResult cr)
        {
            cr.IsAlertMsg = true;
            UCLHLCLAIHANXX LHLCLAIHANXX = this.Parent.FindControl("UCLHLCLAIHANXX") as UCLHLCLAIHANXX;
            if (LHLCLAIHANXX == null)
            {
                cr.IsSuccess = false;
                cr.Msg = "";
                return;
            }
            ASPxGridView gvLH = LHLCLAIHANXX.FindControl("gvList") as ASPxGridView;
            if (gvLH == null)
            {
                cr.IsSuccess = false;
                cr.Msg = "";
                return;
            }
            string cid = "";
            //string retstr = "";
            string laihanbh = "";
            string yonghuhs = "";
            for (int i = 0; i < gvLH.VisibleRowCount; i++)
            {
                CheckBox ck = (CheckBox)gvLH.FindRowCellTemplateControl(i, (GridViewDataColumn)gvLH.Columns[0], "cid");
                HiddenField hid = (HiddenField)gvLH.FindRowCellTemplateControl(i, (GridViewDataColumn)gvLH.Columns[0], "id");
                HiddenField laihan = (HiddenField)gvLH.FindRowCellTemplateControl(i, (GridViewDataColumn)gvLH.Columns[0], "laihanbh");
                HiddenField yonghuh = (HiddenField)gvLH.FindRowCellTemplateControl(i, (GridViewDataColumn)gvLH.Columns[0], "yonghuh");

                if (ck.Checked)
                {
                    cid += hid.Value + ",";
                    laihanbh += "'" + laihan.Value + "',";
                    yonghuhs += yonghuh.Value + ",";
                }
            }
            if (cid.Trim().Length > 0)
            {
                laihanbh = laihanbh.Remove(laihanbh.LastIndexOf(','));
                cid = cid.Remove(cid.LastIndexOf(','));
                int? NextLCZT = 0;
                string NextLCMC = "";
                _sphelper.P_YS_LH_LIUCHENGPZ_LHLX(this.LAIHANLX, this.LAIHANLCBH, out NextLCZT, out NextLCMC);

                string col = " I_LIUCHENGBH=" + NextLCZT + ",S_CAOZUOR='{0}',D_CAOZUOSJ=sysdate ";
                string where = "ID in ({0}) ";
                if (NextLCZT < 0)
                {

                 }

                col = string.Format(col, LoginInfo.CurrentUser.UserID.ToString());
                where = string.Format(where, cid);
                int count = 0;
                if (!CheckValue(laihanbh, out count))
                {
                    cr.IsSuccess = false;
                    cr.Msg = "";
                    return;
                }
                
                int succcess = 0;
                if (NextLCZT >= 0)
                {
                    succcess = blllh.UpdateYS_LH_LAIHANXXesDynamic(col, where);
                }
                else
                {
                    string[] arr = laihanbh.Split(',');
                    string[] arry = yonghuhs.Split(',');
                    for (int i = 0; i < arr.Length; i++)
                    {
                        if (arr[i].Replace("'", " ").Trim().Length > 0)
                        {
                            int? RetValue = 0;
                            _sphelper.P_YS_LH_UPDATETIAOZHENGJH(arr[i].Replace("'", " ").Trim(), arry[i].Trim(), this.LAIHANLCBH, LoginInfo.CurrentUser.UserID, LoginInfo.CurrentUser.UserID.ToString(), out RetValue);
                            if (RetValue == 1)
                            {
                                UpdateYS_YG_YONGHUXX(arr[i].Replace("'", " ").Trim());
                            }
                        }
                    }

                }
                if (succcess > 0)
                {
                    UpdateLiuChengXX(laihanbh);

                }
                else
                {
                    cr.IsSuccess = false;
                    cr.Msg = "操作失败";
                    cr.SpecialIndetity = "-2";
                    return;
                }
               
            }
            else
            {
                cr.IsSuccess = false;
                cr.Msg = "请选择要提交的数据";
                cr.SpecialIndetity = "-1";
                return;
            }
            cr.IsSuccess = true;
            cr.Msg = "操作成功";
            return;
        }
        /// <summary>
        /// 更新流程记录
        /// </summary>
        /// <param name="laihanbh"></param>
        private void UpdateLiuChengXX(string laihanbh)
        {
            string[] arr = laihanbh.Split(',');
            int? NextLCZT = 0;
            string NextLCMC = "";
            _sphelper.P_YS_LH_LIUCHENGPZ_LHLX(this.LAIHANLX, this.LAIHANLCBH, out NextLCZT, out NextLCMC);
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i].Trim().Length > 0)
                {
                    if (NextLCZT != null && NextLCZT > 0)
                    {
                        ///添加流程记录信息
                        YS_LH_LAIHANLCJL lcjl = new YS_LH_LAIHANLCJL();
                        lcjl.D_CAOZUORQ = DateTime.Now;
                        lcjl.D_STARTDATE = DateTime.Now;
                        lcjl.I_CAOZUOR = LoginInfo.CurrentUser.UserID;
                        lcjl.I_LAIHANLX = this.LAIHANLX;
                        lcjl.I_LIUCHENGBH = NextLCZT;
                        lcjl.ID = 0;

                        DataTable lcxx = lcbll.SelectYS_LH_LAIHANLCJLsDynamic(string.Format(" S_LAIHANBH={0} and I_LIUCHENGBH={1} and i_jlzt=0 ", arr[i], NextLCZT), "", null);
                        if (lcxx != null && lcxx.Rows.Count > 0)
                        {
                            lcjl.ID = Convert.ToInt32(lcxx.Rows[0]["ID"]);
                        }
                        lcjl.S_LAIHANBH = arr[i].Replace("'", " ").Trim();

                        lcjl.S_LIUCHENGMC = NextLCMC;

                        lcbll.InsertOrUpdate(lcjl);
                    }
                    else
                    {

                    }

                    lcbll.UpdateYS_LH_LAIHANLCJLsDynamic(string.Format("D_ENDDATE=sysdate,I_CAOZUOR={0},D_CAOZUORQ=sysdate", LoginInfo.CurrentUser.UserID), " I_LIUCHENGBH=" + this.LAIHANLCBH + " and S_LAIHANBH='" + arr[i].Replace("'", " ").Trim() + "'");
                }
            }
        }

        /// <summary>
        /// 审核通过更新用户信息
        /// </summary>
        /// <param name="laihanbh"></param>
        private void UpdateYS_YG_YONGHUXX(string laihanbh)
        {
            DataTable oldyh = laihanyhxx.SelectYS_LH_YONGHUXXesDynamic(string.Format(" I_JLZT=0 and S_LAIHANBH='{0}'", laihanbh), "", null);
            if (oldyh != null && oldyh.Rows.Count > 0)
            {
                DataRow dr = oldyh.Rows[0];
                string col = "S_LIANXIDH='{0}',S_LIANXIR='{1}',S_YONGHUM='{2}',S_YOUBIAN='{3}',S_LIANXIBM='{4}',S_DIZHI='{5}' ";

                string where = "S_YONGHUH='{0}'";
                col = string.Format(col, dr["S_LIANXIDH"], dr["S_LIANXIR"], dr["S_YONGHUM"], dr["S_YOUBIAN"], dr["S_LIANXIBM"], dr["S_DIZHI"]);
                where = string.Format(where, dr["S_YONGHUBH"]);
                yhbll.UpdateYS_YG_YONGHUXXesDynamic(col, where);
            }
        }
        /// <summary>
        /// 验证指定流程是否复核提交条件
        /// </summary>
        /// <param name="laihanbh"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private bool CheckValue(string laihanbh, out int count)
        {
            string where = string.Format(" S_LAIHANBH in ({0}) and i_jlzt=0 ", laihanbh);
            switch (this.LAIHANLCBH)
            {
                case 30:
                    where += " and (S_YEWUYJY is null or I_YEWUYJY is null)";
                    break;
                case 40:
                    where += " and (I_ZHUREN is null or S_ZHUREN is null)";
                    break;
                case 50:
                    where += " and (I_JIESHUIKZ is null or S_JIESHUIKZ is null)";
                    break;
                case 60:
                    where += " and (I_JICAIKZ is null or S_JICAIKZ is null)";
                    break;
                case 70:
                    where += " and (I_CHUZHANG is null or S_CHUZHANG is null)";
                    break;
            }
            DataTable yuetz = bllyue.SelectYS_LH_YUETIAOZsDynamic(where, "", null);
            count = 0;
            if (yuetz != null && yuetz.Rows.Count > 0)
            {
                count = yuetz.Rows.Count;
                return false;
            }
            return true;
        }
        private void SetDisplay()
        {
            switch (this.LAIHANLCBH)
            {
                case 30:

                    td_YeWUY_TOP.Visible = false;
                    txtYeWuYJYL.Visible = false;
                    txtZhuRenFHL.Visible = false;

                    td_JieShuiKZ_TOP.Visible = false;
                    txtJieShuiKZSHL.Visible = false;
                    td_JiCaiKZ_TOP.Visible = false;
                    td_ZhuRen_TOP.Visible = false;
                    txtJiCaiKZFSL.Visible = false;

                    Div_YiJian.Visible = false;

                    Div_ZhuRen.Visible = false;
                    Div_JieShuiKZ.Visible = false;
                    Div_JiCaiKZ.Visible = false;
                    Div_ChuZhang.Visible = false;

                    Table_YeWuY.Visible = false;
                    //DIV_YeWuYHKZ.Visible = false;
                   // DIV_YeWwY_ZhuR.Visible = false;
                    Div_YiJian.Visible = false;
                   // DIV_YeWuYYJ.Visible = false;
                    break;
                case 40:
                    CK_FuShenXG.Visible = false;
                    //DIV_YeWwY_ZhuR.Visible = false;
                    //DIV_YeWuYHKZ.Visible = false;
                    Div_YiJian.Visible = false;

                    Div_YeWuY_SR.Visible = false;

                    Div_JieShuiKZ.Visible = false;
                    Div_JiCaiKZ.Visible = false;
                    Div_ChuZhang.Visible = false;


                    td_ZhuRen_TOP.Visible = false;
                    txtZhuRenFHL.Visible = false;
                    td_JieShuiKZ_TOP.Visible = false;
                    txtJieShuiKZSHL.Visible = false;
                    td_JiCaiKZ_TOP.Visible = false;
                    txtJiCaiKZFSL.Visible = false;
                    break;

                case 50:
                    CK_FuShenXG.Visible = false;
                    //DIV_YeWuYHKZ.Visible = false;

                    tr_JieShuiKZ.Visible = false;
                    tr_JiCaiKZ.Visible = false;
                    tr_ChuZhang.Visible = false;

                    td_JieShuiKZ_TOP.Visible = false;
                    td_JiCaiKZ_TOP.Visible = false;
                    txtJieShuiKZSHL.Visible = false;
                    txtJiCaiKZFSL.Visible = false;

                    Div_YeWuY_SR.Visible = false;

                    Div_ZhuRen.Visible = false;
                    Div_JiCaiKZ.Visible = false;
                    Div_ChuZhang.Visible = false;
                    break;
                case 60:
                    CK_FuShenXG.Visible = true;
                    //DIV_YeWwY_ZhuR.Visible = false;
                    tr_JiCaiKZ.Visible = false;
                    tr_ChuZhang.Visible = false;

                    txtJiCaiKZFSL.Visible = false;
                    td_JiCaiKZ_TOP.Visible = false;

                    Div_YeWuY_SR.Visible = false;
                    Div_ZhuRen.Visible = false;
                    Div_JieShuiKZ.Visible = false;

                    Div_ChuZhang.Visible = false;
                    break;
                case 70:
                    //DIV_YeWwY_ZhuR.Visible = false;
                    //DIV_YeWuYHKZ.Visible = false;
                    tr_ChuZhang.Visible = false;

                    Div_YeWuY_SR.Visible = false;
                    Div_ZhuRen.Visible = false;
                    Div_JieShuiKZ.Visible = false;

                    Div_JiCaiKZ.Visible = false;
                    break;
            }
        }

        public void SetXiuGai(bool status)
        {
            if (Div_YeWuY_SR.Visible)
            {
                txtYeWuJYL.Enabled = status;
                txtYeWuYJY.Enabled = status;
            }
            if (Div_ZhuRen.Visible)
            {
                txtI_ZhuRenFHL.Enabled = status;
                txtZhuRenYJ.Enabled = status;
            }
            if (Div_JieShuiKZ.Visible)
            {
                txtI_JieShuiKZSHL.Enabled = status;
                txtS_JieShuiKZSHL.Enabled = status;
            }
            if (Div_JiCaiKZ.Visible)
            {
                txtI_JiCaiKZFSL.Enabled = status;
                txtS_JiCaiKZFSL.Enabled = status;
            }
            if (Div_ChuZhang.Visible)
            {
                txtI_ChuZhangSPL.Enabled = status;
                txtS_ChuZhangYJ.Enabled = status;
            }
        }
    
    }
}